<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>小飞象-会员中心-店铺管理</title>
    <link rel="stylesheet" href="//at.alicdn.com/t/font_810097_mgs6xzz1oj.css">
    <link rel="stylesheet" href="../css/common/reset.css">
    <link rel="stylesheet" href="../layui/css/layui.css">
    <link rel="stylesheet" href="../css/reset-layui.css">
    <link rel="stylesheet" href="../css/header.css">
    <link rel="stylesheet" href="../css/common/nav.css">
    <link rel="stylesheet" href="../css/common/aside.css">
    <link rel="stylesheet" href="../css/common/content.css">
    <link rel="stylesheet" href="../css/storeMage.css">
</head>

<body>
    <header>
        <div class="wrapper">
            <div class="clearfix headerBox">
                <h1 class="fl logo">
                    <a href="">小飞象</a>
                </h1>
                <!-- <div class="fl alipayName">支付宝充值账号: <b class="redColor">156****8656</b>开户人: <b class="redColor">陈小窝</b></div> -->
                <div class="fr logOut">退出</div>
                <div class="fr userName"></div>
            </div>
        </div>
    </header>
    <div class="mhNav">
        <ul class="navMenuBox">
            <li>
                <a href="../index.html">
                    飞象首页
                </a>
            </li>
            <li class="memberUser">
                <a href="javascript:;" class="active">
                    会员中心
                    <!-- <i class="iconfont icon-arrow-up mhArrowIcon"></i>
                    <i class="iconfont icon-arrow-down mhArrowIcon"></i> -->
                </a>
                <ul class="mhColumnSide">
                    <li>
                        <a href="basicInfo.html">基本资料</a>
                    </li>
                    <li>
                        <a href="storeMage.html">店铺管理</a>
                    </li>
                    <li>
                        <a href="readjustNum.html">调整单量</a>
                    </li>
                    <li>
                        <a href="/goodsMage.html">商品管理</a>
                    </li>
                </ul>
            </li>
            <li>
                <a href="javascript:;">
                    计划管理
                    <!-- <i class="iconfont icon-arrow-up mhArrowIcon"></i>
                    <i class="iconfont icon-arrow-down mhArrowIcon"></i> -->
                </a>
                <ul class="mhColumnSide">
                    <li>
                        <a href="../plan/newPlan.html">新建计划</a>
                    </li>
                    <li>
                        <a href="../plan/planMage.html">计划管理</a>
                    </li>
                </ul>
            </li>
            <li>
                <a href="javascript:;">
                    订单管理
                    <!-- <i class="iconfont icon-arrow-up mhArrowIcon"></i>
                    <i class="iconfont icon-arrow-down mhArrowIcon"></i> -->
                </a>
                <ul class="mhColumnSide">
                    <li>
                        <a href="../order/orderMage.html">订单管理</a>
                    </li>
                </ul>
            </li>
            <li>
                <a href="javascript:;">
                    资金管理
                    <!-- <i class="iconfont icon-arrow-up mhArrowIcon"></i>
                    <i class="iconfont icon-arrow-down mhArrowIcon"></i> -->
                </a>
                <ul class="mhColumnSide">
                    <li>
                        <a href="../capital/inAccout.html">账号充值</a>
                    </li>
                    <li>
                        <a href="../capital/transferMage.html">转账管理</a>
                    </li>
                    <li>
                        <a href="../capital/orderMage/dailyTaskDes.html">订单信息</a>
                    </li>
                    <li>
                        <a href="../capital/expressForm.html">获取快递底单</a>
                    </li>
                </ul>
            </li>
            <li>
                <a href="">在线客服</a>
            </li>
        </ul>
    </div>
    <div class="wrapper mainBomContent">
        <!-- 会员中心-基本资料 -->
        <div class="asideMenu">
            <ul>
                <li class="title">
                    <i class="iconfont icon--"></i> 会员中心
                </li>
                <li>
                    <a href="basicInfo.html">基本资料</a>
                </li>
                <li class="active">
                    <a href="storeMage.html">店铺管理</a>
                </li>
                <!-- <li>
                    <a href="">软件授权认证</a>
                </li> -->
                <li>
                    <a href="readjustNum.html">调整单量</a>
                </li>
                <li>
                    <a href="/goodsMage.html">商品管理</a>
                </li>
            </ul>
        </div>
        <div class="rightContent">
            <div class="storeMageView">
                <div class="bindStoreBox">
                    <ul>
                        <li>
                            <p class="fl bindText">绑定店铺：<b class="length"></b></p>
                            <p class="fl bindStore fBindTbStore">绑定新店铺</p>
                        </li>
                        <!-- <li>
                            <p class="fl bindText">天猫店铺：1个</p>
                            <p class="fl bindStore fBindTmStore">绑定新店铺</p>
                        </li> -->
                    </ul>
                </div>
                <div class="showTbStoreBox">
                    <h3 class="storeTitle">
                        淘宝店铺
                        <span class="redColor">（对店铺开启推广标记，可减少90%以上的淘宝客或农村淘宝佣金损失和纠纷，如有需要请联系商家顾问操作）</span>
                    </h3>
                    <table class="layui-table" id="storeShow">
                        <colgroup>
                            <col width="200">
                            <col>
                            <col width="120">
                            <col width="340">
                            <col width="120">
                            <col width="251">
                            <col width="200">
                        </colgroup>
                        <thead>
                            <tr>
                                <th>店铺名称</th>
                                <th>所属平台</th>
                                <th>状态</th>
                                <th>发货人信息</th>
                                <th>发货重量</th>
                                <th>店铺推广状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody class="storeShow"></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <script src="../js/jquery.min.js"></script>
    <script src="../layui/layui.js"></script>
    <script>
        $(".mhNav .navMenuBox > li > a").click(function (event) {
            if ($(this).siblings('ul').is(':visible')) {
                $(this).siblings('ul').stop(true, true).slideUp();
                $(this).removeClass('active')
            } else {
                $(this).siblings('ul').stop(true, true).slideDown().parents('li').siblings().find('ul').stop(
                    true, true).slideUp();
                $(this).addClass('active').parents('li').siblings().find('a').removeClass('active');
            }
        });
    </script>
    <script src="../js/jsonselect.js"></script>
    <script src="../js/jquery.cookie.js"></script>
    <script>
        var mid = $.cookie('id');
        if (mid == null || mid == "" || !mid || mid == undefined) {
            window.location.href = "/login.html";
        }
        $.ajax({
            url: 'http://47.92.174.143:8888/v1/client/shop/merchants/' + mid,
            type: 'GET',
            dataType: 'json',
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                console.log("请求到的数据", data)
                var _Success = data.code;
                var html = "";
                if (_Success == 200) {
                    if (!data.data.length == "" || !data.data.length == null || !data.data.length ==
                        undefined) {
                        $(".length").html(data.data.length + "个");
                    } else {
                        $(".length").html("未绑定店铺");
                    }
                    for (var i = 0; i < data.data.length; i++) {
                        var merchantsId = $.cookie('shopName', data.data[i].merchantsId);
                        // console.log("你是个什么", merchantsId);
                        var checkTaobaoGuest = data.data[i].checkTaobaoGuest == 1 ? '已开启' : '已关闭';
                        var checkTaobaoRural = data.data[i].checkTaobaoRural == 1 ? '已开启' : '已关闭';
                        var checkThroughTrain = data.data[i].checkThroughTrain == 1 ? '已开启' : '已关闭';
                        var status;
                        switch (status = data.data[i].status) {
                            case 0:
                                status = "待审核"
                                break;
                            case 1:
                                status = "停用"
                                break;
                            default:
                                status = "启用"
                                break;
                        }
                        html += '<tr><td>' + data.data[i].shopName + '</td><td>' + data.data[i].shopPlatform +
                            '</td><td><label>[</label>' + status +
                            '<label>]</label></td><td class="tLeft"><p>姓名：' + data.data[i].shopShipperName +
                            '</p><p>电话：' + data.data[i].shopShipperTel + '</p><p>地址：' + data.data[i].shopShipperAddress +
                            data.data[i].detailedAddress +
                            '</p><p class="fr blueColor fEditAddress cursor editShopInfo" id="' + i +
                            '">编辑</p></td><td>' + data.data[i].weight +
                            '/kg</td><td class="noPadding"><div class="clearfix cutTopBox"><div class="fl showStaticStore">淘宝客</div><div class="fl staticBox fTips">' +
                            checkTaobaoGuest +
                            '</div></div><div class="clearfix cutTopBox"><div class="fl showStaticStore">农村淘宝客</div><div class="fl staticBox fTips">' +
                            checkTaobaoRural +
                            '<div class="tips">过滤功能已关闭！如需开启请联系商家顾问</div></div></div><div class="clearfix cutTopBoxnoBBorder"><div class="fl showStaticStore">直通车</div><div class="fl staticBox fTips">' +
                            checkThroughTrain +
                            '<div class="tips">过滤功能已关闭！如需开启请联系商家顾问</div></div></div></td><td><a href="https://s.52jisu.com/open/auth.jsp?appId=81584238&state=' + data.data[i].id + '&nick2=' + data.data[i].boundWant + '" class="giveBtn">授权</a><a href="javascript:void(0);" class="readMore fReadMore" data-id=' +
                            i + ' val="' + data.data[i].id + '">查看详情</a><a href="javascript:void(0);" class="delBtn fDel" data-id=' + i +
                            ' val="' + data.data[i].id + '">删除</a></td></tr>';
                    }
                    $(".storeShow").append(html);
                    layui.use('layer', function () {
                        // layer.msg("请求成功");
                        var layer = layui.layer;
                        // $(".fTips").mouseenter(function () {
                        //     let that = $(this);
                        //     layer.tips('过滤功能已关闭！如需开启请联系商家顾问', that);
                        // });
                        $(".fBindTbStore").click(function () {
                            if (data.data.length >= 3) {
                                layer.msg("您已绑定3个店铺");
                                return;
                            }
                            layer.open({
                                type: 2 //此处以iframe举例
                                ,
                                title: '提交淘宝店铺审核资料',
                                area: ['700px', '650px'],
                                shadeClose: true //开启遮罩关闭
                                ,
                                offset: 'auto',
                                scrollbar: true,
                                content: ['storeMage/bindNewTbStore.html'],
                                btn2: function () {
                                    layer.closeAll();
                                },
                                zIndex: layer.zIndex //重点1
                            });
                        });
                        $(".fBindTmStore").click(function () {
                            layer.open({
                                type: 2 //此处以iframe举例
                                ,
                                title: '提交天猫店铺审核资料',
                                area: ['700px', '650px'],
                                shadeClose: true //开启遮罩关闭
                                ,
                                offset: 'auto',
                                scrollbar: true,
                                content: ['storeMage/bindNewTmStore.html'],
                                btn2: function () {
                                    layer.closeAll();
                                },
                                zIndex: layer.zIndex //重点1
                            });
                        });
                        $(".fReadMore").on("click", function (e) {
                            var shopId = $(this).attr("val");
                            console.log("拿到的当前数据的id", shopId);
                            layer.open({
                                type: 2 //此处以iframe举例
                                ,
                                title: '查看详情',
                                area: ['700px', '472px'],
                                shadeClose: true //开启遮罩关闭
                                ,
                                offset: 'auto',
                                scrollbar: true,
                                content: ['storeMage/readMore.html'],
                                success: function (layero, index) {
                                    var iframe = window['layui-layer-iframe' + index];
                                    iframe.child(shopId);
                                },
                                zIndex: layer.zIndex //重点1
                            });
                        });
                        $(".fDel").on("click", function (e) {
                            var shopDelId = $(this).attr("val");
                            console.log("拿到的当前数据的id", shopDelId);
                            layer.open({
                                type: 2 //此处以iframe举例
                                ,
                                title: '删除',
                                area: ['500px', '162px'],
                                shadeClose: true //开启遮罩关闭
                                ,
                                offset: 'auto',
                                scrollbar: true,
                                content: ['storeMage/delStore.html', 'no'],
                                success: function (layero, index) {
                                    var iframe = window['layui-layer-iframe' + index];
                                    iframe.child(shopDelId);
                                },
                                zIndex: layer.zIndex //重点1
                            });
                        });
                        $(".fEditAddress").on("click", function (e) {
                            var shopinfoId = $(e.target).attr('id');
                            console.log(shopinfoId)
                            $.cookie("shopInfo", JSON.stringify(data.data[shopinfoId]));
                            console.log("店铺信息", data.data)
                            layer.open({
                                type: 2 //此处以iframe举例
                                ,
                                title: '编辑发货人信息',
                                area: ['700px', '514px'],
                                shadeClose: true //开启遮罩关闭
                                ,
                                offset: 'auto',
                                scrollbar: true,
                                content: ['storeMage/editAddress.html'],
                                btn2: function () {
                                    layer.closeAll();
                                },
                                zIndex: layer.zIndex //重点1
                            });
                        })
                    })
                } else {
                    layer.msg(data.data);
                }
            }
        });
        $.ajax({
            type: "get",
            url: "http://47.92.174.143:8888/v1/client/merchants/" + mid,
            dataType: 'json',
            success: function (data) {
                console.log("请求数据为", data.data)
                // 存储总额
                if (data.data == null || !data.data) {
                    layer.msg('数据出错,请重新登录', {
                        icon: 5,//提示的样式
                        time: 6000, //6秒关闭（如果不配置，默认是3秒）//设置后不需要自己写定时关闭了，单位是毫秒
                        end: function () {
                            location.href = '/login.html';
                        }
                    });
                } else {
                    $(".userName").html(data.data.loginId);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                // console.log(XMLHttpRequest);
                // console.log(textStatus);
                // console.log(errorThrown);
            }
        });
    </script>
</body>

</html>